package com.pxst.fi.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.pxst.fi.entity.SysThirdPartySettingEntity;
import com.pxst.fi.req.ThirdPaySettingReq;
import com.pxst.fi.resp.ThirdPaySettingResp;
import com.pxst.fi.service.SysThirdPartySettingService;
import com.pxst.fi.mapper.SysThirdPartySettingMapper;
import com.pxst.resp.ApiResp;
import com.pxst.resp.PageResp;
import icu.mhb.mybatisplus.plugln.base.service.impl.JoinServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

/**
* @author notch
* @description 针对表【sys_third_party_setting(第三方支付设置(tpi110))】的数据库操作Service实现
* @createDate 2023-09-22 16:44:24
*/
@Service
public class SysThirdPartySettingServiceImpl extends JoinServiceImpl<SysThirdPartySettingMapper, SysThirdPartySettingEntity>
    implements SysThirdPartySettingService{

    private SysThirdPartySettingMapper thirdPartySettingMapper;

    @Override
    public ApiResp<PageResp<ThirdPaySettingResp>> getThirdPaySetting(ThirdPaySettingReq thirdPaySettingReq) {
        LambdaQueryWrapper<SysThirdPartySettingEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(SysThirdPartySettingEntity::getMerchantId, 0);
        queryWrapper.eq(SysThirdPartySettingEntity::getCurrency, thirdPaySettingReq.getCurrency());
        queryWrapper.eq(!ObjectUtils.isEmpty(thirdPaySettingReq.getType()), SysThirdPartySettingEntity::getType, thirdPaySettingReq.getType());
        queryWrapper.eq(!ObjectUtils.isEmpty(thirdPaySettingReq.getTxnMode()), SysThirdPartySettingEntity::getTxnMode, thirdPaySettingReq.getTxnMode());
        queryWrapper.orderByDesc(SysThirdPartySettingEntity::getCreatedAt);
        PageHelper.startPage(thirdPaySettingReq.getPage(), thirdPaySettingReq.getRp());
        Page<SysThirdPartySettingEntity> page = (Page<SysThirdPartySettingEntity>) list(queryWrapper);
        return ApiResp.page(page);
    }
}




